package com.rolfhoward.video.record.camera

/**
 *@author wuqiubin
 *@date 2022/12/9
 *@Describe 相机管理类
 */
class CameraController private constructor():ICameraController{

    private var isInit:Boolean = false
    private var mCameraCallBack:CameraCallBack? = null
    private var mCameraParams:CameraParams? = null

    companion object{
        private var instance:CameraController? = null
        fun getInstance():CameraController{
            instance?: synchronized(this){
                instance?:CameraController().also { instance = it }
            }
            return instance!!
        }
    }

    /**
     * 初始化实例
     * */
    init {
        mCameraParams = CameraParams.getInstance()
    }

    /**
     * 打开相机预览
     * */
    override fun openCameraPreview(){
        if (!isInit) {
            isInit = true
            mCameraCallBack?.ratioCallBack(mCameraParams?.mRatioType)
        }
    }

    fun setCameraCallback(callBack:CameraCallBack){
        this.mCameraCallBack = callBack
    }

}